package org.soarsky.wealthchengdu.module.info;

import java.util.ArrayList;
import java.util.List;

import org.soarsky.wealthchengdu.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 参会指南适配器
 * 
 * @author huang
 * 
 */
public class GuideCDlistAdapter extends BaseAdapter {

	private Context context;
	private List<GuideAppbean> list;// 数据源

	public GuideCDlistAdapter(Context context) {
		list = new ArrayList<GuideAppbean>();
		this.context = context;
	}

	public void setlistdata(List<GuideAppbean> list) {
		this.list = list;
		this.notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int positionitem) {
		return positionitem;
	}

	@Override
	public long getItemId(int positionid) {
		return positionid;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		HolderView holderview = null;
		if (convertView == null) {
			holderview = new HolderView();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.guide_item, null);
			holderview.guideTitletv = (TextView) convertView
					.findViewById(R.id.guide_item_title);
			holderview.guideImage = (ImageView) convertView
					.findViewById(R.id.guide_item_image);
			convertView.setTag(holderview);
		} else {
			holderview = (HolderView) convertView.getTag();
		}
		holderview.guideTitletv.setText(list.get(position).guidetitle);
		holderview.guideImage.setImageResource(list.get(position).image);
		return convertView;
	}

	class HolderView {
		TextView guideTitletv;
		ImageView guideImage;
	}
}
